const path = require('path');
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
//const webpack = require('webpack');

module.exports = {
	entry: {
		app: './src/entrys/entry_merge.js'
	},
	plugins: [
		new CleanWebpackPlugin({
			cleanStaleWebpackAssets: false // true清理所有文件， false只删除变动过的文件(如执行 npm run watch时dist下的index.html时没有改变的，不需要删除)
		}), // 每次打包前删除dist文件夹
		new HtmlWebpackPlugin({
			title: 'Production'
		})
	],
	optimization: {
        splitChunks: {	// 提取模板
            chunks: 'all',
            name:'manifest'
        }
    },
	output: {
		filename: '[name].bundle.js',
		path: path.resolve(__dirname, '../dists/distMerge')
	}
};